package com.sword.pay.solon;

import com.sword.common.strategy.ISCommonStrategy;
import com.sword.pay.PayManager;
import com.sword.pay.repository.config.ISPayClientConfig;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.Plugin;

/**
 * @description: 注入类
 * @author：Lv.RJ
 * @version: 1.0.0
 * @create: 2025/02/17
 **/
public class XPluginImp implements Plugin {

    @Override
    public void start(AppContext context) {
//        context.beanMake(SaSsoAutoConfigure.class);

   /*     // 注入上下文Bean
        SaManager.setSaTokenContext(new SaContextForSolon());

        // 注入JSON解析器Bean
        SaManager.setSaJsonTemplate(new SaJsonTemplateForSnack3());*/

        //注入配置Bean
        /*SaTokenConfig saTokenConfig = Solon.cfg().getBean("sa-token", SaTokenConfig.class);
        if (saTokenConfig != null) {
            SaManager.setConfig(saTokenConfig);
        }*/

   /*
        // 注入单个bean
        context.getBeanAsync(ISInvoiceDriverRepository.class, bean -> {
            InvoiceManager.setISInvoiceDriverRepository(bean);
        });*/

        //订阅注入批量的bean
        context.subBeansOfType(ISCommonStrategy.class, bean ->  PayManager.setISInvoiceDriverRepository(bean));

        context.subBeansOfType(ISPayClientConfig.class, bean ->  PayManager.setBeanConfig(bean));
    }
}